package com.cobra.rdd.builder

import org.apache.spark.{SparkConf, SparkContext}

object Spark02_RDD_File_Par2 {
  def main(args: Array[String]): Unit = {
    //准备环境
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)
    //创建rdd
    //如果数据源为多个文件，计算分区时以文件为单位进行分区
    val rdd = sc.textFile("datas/word.txt,datas/word1.txt",2)
    val partitions = rdd.getNumPartitions
    println(partitions)
    rdd.saveAsTextFile("outputFile")
    //关闭环境
    sc.stop()
  }
}
